How to change the style of disabled and checked checkboxes?
How to change the style of disabled and checked checkboxes?
I completed my post-graduation in 2013 in the engineering field. Engineering is the application of science and math to solve problems. Engineers figure out how things work and find practical uses for scientific discoveries. Scientists and inventors often get the credit for innovations that advance the human condition, but it is engineers who are instrumental in making those innovations available to the world. I love pet animals such as dogs, cats, etc.
Aryan Kumar
18-Aug-2023To change the style of disabled and checked checkboxes, you can use the
disabledandcheckedCSS properties.The
disabledproperty disables the checkbox and prevents it from being checked. Thecheckedproperty checks the checkbox.The following CSS code changes the style of disabled and checked checkboxes:
CSS
In this code, the
.disabledclass is applied to disabled checkboxes. Theopacityproperty is set to 0.5, which makes the checkbox translucent. Thecursorproperty is set tonot-allowed, which prevents the checkbox from being clicked.The
.checkedclass is applied to checked checkboxes. Thebackground-colorproperty is set to #2196F3, which is the color of the checked checkbox. Theborder-colorproperty is also set to #2196F3.You can also use the
:disabledand:checkedpseudo-classes to style disabled and checked checkboxes. The following CSS code is equivalent to the previous code:CSS
In this code, the
.checkboxclass is applied to all checkboxes. The:disabledpseudo-class is applied to disabled checkboxes and the:checkedpseudo-class is applied to checked checkboxes.